package espacokidsadm.modelo.dao.impl;

import java.util.List;

import espacokidsadm.modelo.dao.Dao;
import espacokidsadm.modelo.entity.Cargo;


public class CargoDAO extends Dao {

	private static final long serialVersionUID = -8652566999470645721L;
	
	public Cargo salvar(Cargo cargo) {
		if(cargo.getId() == null)
			getEm().persist(cargo);
		else
			getEm().merge(cargo);
		
		return cargo;
	}


	public Cargo getById(Integer id) {
		return getPojo(Cargo.class, id);
	}

	public List<Cargo> getTodos() {
		return getList(Cargo.class, "select cargo from Cargo cargo order by cargo.nomeCargo");
	}

}
